package com.work.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.work.bean.UserBean;
import com.work.mapper.UserMapper;
import com.work.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/users")
public class UserController {
    @Resource
    private IUserService userService;
    @Resource
    private UserMapper userMapper;

    @RequestMapping("/login")
    @ResponseBody
    public UserBean login(String userName,String userPwd){
        QueryWrapper<UserBean> wrapper = new QueryWrapper<>();
        wrapper.eq("user_name",userName).eq("user_pwd",userPwd);
        System.out.println(userName);
        return userService.getOne(wrapper);
    }

    @RequestMapping("/add")
    public void addUser(UserBean userBean){
        userMapper.insert(userBean);
    }


}
